<?php

namespace app\admin\controller;
use think\Db;
use think\Request;
use think\Controller;
class Advice extends Common{

    public function index(){

        if(request()->ispost()){

            if (!session('user.user_id')) {
                $this->redirect('login/index');
            }else{

                 $data = db('advice')->find();
                 $this->assign('advice',$data);
                 return view();
            }
        }

    }

    public function add(){
        if(request()->ispost()){
            $data=input('post');
            $data['userid']=session('user.user_id');
            $data['username']=session('user.nickname');
            $data['adddate']=date('Y-m-d H:i:s',time)
            $Add_adv=db('advice')->insert($data);
            $this->assign('add_adv',$Add_adv);
            return view();
        }
    }


}

?>